home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #1
/
Amiga Plus 1995 #1.iso
/
fish-disketten
/
fish_691-700
/
d695
/
icalc
/
scripts
/
bern.ic
< prev
next >
Wrap
Text File
|
1994-12-13
|
487b
|
26 lines
# Bernoulli number function
#
# B(n) takes INTEGRAL values, and returns the nth Bernoulli number, with
# precision better than 6e-8.
# From "Atlas of Functions", section 4:8
#
# mws, February 1992.
func B(n) = {
local fv, gv, factn
if (frac(n/2) != 0) {
n = n-2
fv = (sgn(n)-1)/4
} else {
fv = 1
if (n != 0) {
factn = fact(n)
gv = (n+1)*factn/(fact(n/2)*2^(n/2))
fv = (fv+3^-n)*factn/(PI^n*(2^n-1))
fv = 0.5+floor(2*fv*gv)
fv = fv*(4*frac(n/4)-1)/gv
}
}
}